<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>

    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="__STATIC__/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <link href="__STATIC__/admin/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/admin/css/style.css?v=4.1.0" rel="stylesheet">
    <script src="__STATIC__/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="__STATIC__/admin/js/layer/layer.js"></script>
    <script>if(window.top !== window.self){ window.top.location = window.location;}</script>
</head>

<body class="gray-bg">

    <div class="middle-box text-center loginscreen  animated fadeInDown">
        <div>
            <div>
                <h1 class="logo-name"></h1>
            </div>
            <h3>欢迎使用</h3>

            <form class="m-t" role="form" action="">
                <div class="form-group">
                    <input type="text" class="form-control" name="account" placeholder="用户名" required="">
                </div>
                <div class="form-group">
                    <input type="password" class="form-control" name="password" placeholder="密码" required="">
                </div>
                <div class="form-group">
                    <input type="text" class="form-control" name="code" required="" placeholder="验证码" style="float:left;width: 60%"><img class="yzm" src="/admin/Login/captchaImg" style="width:38%;height:34px;padding-left: 2%">
                </div>
                <button type="submit" class="btn btn-primary block full-width m-b">登 录</button>
            </form>
        </div>
    </div>
    
    <script>
        $(".m-t").submit(function(e){
            var account = $("input[name='account']").val();
            var password = $("input[name='password']").val();
            var code = $("input[name='code']").val();

            $.post("{:url('Login/do_login')}",{account:account,passwd:password,code:code},function(result){
                if(result.code == '0'){
                    var index = layer.alert(result.msg, {
                      skin: 'layui-layer-molv' //样式类名
                      ,closeBtn: 0
                    }, function(){
                        layer.close(index);
                    });
                }else{
                    location.href = result.url;
                }
            });

            return false;
        });

        $(document).ready(function() {
            $(".yzm").click(function(){
                if( $(this).attr("src").indexOf('?')>0){
                    $(this).attr("src", $(this).attr("src")+'&random='+Math.random());
                }else{
                    $(this).attr("src", $(this).attr("src").replace(/\?.*$/,'')+'?'+Math.random());
                }
            });
        });
    </script>
</body>

</html>
